import axios from 'axios'
import store from '@/store'
// import { Message } from 'element-ui'
// import { Message } from 'element-ui'
// import router from '@/router'
// import { MessageBox, Message } from 'element-ui'
// import store from '@/store'

// create an axios instance
const service = axios.create({
  baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
  timeout: 5000 // request timeout
})

// 请求拦截器
service.interceptors.request.use(config => {
  // 在发请求之前，手动添加token
  if (store.state.user.token) {
    config.headers.Authorization = `Bearer ${store.state.user.token}`
  }
  return config
})

// 响应拦截器
service.interceptors.response.use()

export default service
